package org.panda.framework.core;

import java.util.Collections;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 
 * <description></description>
 * @project panda-framework
 * @author Johnny Liu
 * @date 2020-7-30
 *
 */
public abstract class ResponseBase<T> {

	public static final int SUCCESS = 0;
	public static final int FAILD = 1;
	public static final String SUCCESS_STATUS = "000_000_0000";
	public static final String FAILD_STATUS = "000_000_0001";
	
	public static final String SUCCESS_MSG = "执行成功";
	public static final String FAILD_MSG = "internal error";


	public static final String TOKEN_VALID = "12021";
	//private int result;
	/**
	 * error code
	 */
	//private String code;
	private String status;
	private List<String> messages;
	
	public ResponseBase() {
		super();
	}
	
	public ResponseBase(String status, String message) {
		this(status,Collections.singletonList(message));
	}
	
	public ResponseBase(String status, List<String> messages) {
		super();
		this.status = status;
		this.messages = messages;
	}
	
	/*public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public int getResult() {
		return result;
	}
	public void setResult(int result) {
		this.result = result;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	
	@JsonIgnore
	public boolean isSuccess(){
		return result == SUCCESS;
	}*/
	@JsonIgnore
	public boolean isSuccess(){
		return SUCCESS_STATUS.equals(status);
	}
	
	public String getStatus() {
		return status;
	}
	
	public void setStatus(String status) {
		this.status = status;
	}
	
	public List<String> getMessages() {
		return messages;
	}
	
	public void setMessages(List<String> messages) {
		this.messages = messages;
	}
	
	@Override
	public String toString() {
		return "ResponseBase [status=" + status + ", message=" + messages + "]";
	}
}
